package Work04.Task03;

/**
 * @Author: lu
 * @Date: 2021/9/14 11:50
 * @Description:
 */
public class Tips02 extends Thread{
    private static int tickets = 100;
    @Override
    public void run() {
        while (true){
            synchronized(Tips02.class) {
                if (tickets <= 0) {
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName()+"这是第"+tickets--+"张票");
            }
        }
    }
}
